package cn.springboot.health;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.boot.actuate.metrics.GaugeService;
import org.springframework.stereotype.Component;

/**
 * @author liufl E-mail:Huberier@allpyra.com
 * @version 创建时间：2017年9月27日 下午2:10:05 类说明
 */
@Component
public class MetricsService {
	private final CounterService counterService;
	private final GaugeService gaugeService;

	@Autowired
	public MetricsService(CounterService counterService, GaugeService gaugeService) {
		this.counterService = counterService;
		this.gaugeService = gaugeService;
	}

	public void exampleCounterMethod() {
		this.counterService.increment("login.count");
		// reset each minute
	}

	public void exampleGaugeMethod() {
		this.gaugeService.submit("cache.hit", 80.0);
	}
}
